package com.xwj.service.database1.impl;

import com.xwj.dao.database1.OrderMapper;
import com.xwj.domain.database1.Order;
import com.xwj.service.database1.OrderService;
import com.xwj.service.database2.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author xwj
 * @date 2020/12/11
 */
@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;
    @Autowired
    private StorageService storageService;

    @Override
    @Transactional(value = "dataTransactionManager1", rollbackFor = Exception.class)
    public void create(Order order) {
        orderMapper.create(order);
        storageService.decrease(order.getProductId(), order.getCount());
        int i = 1 / 0;
    }
}
